package com.hexacta.hrs.web.struts.actions.feedbacks;

import java.util.List;

import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.job.JobFunction;

import com.opensymphony.xwork2.ActionSupport;

public class SendRemindersAction extends ActionSupport {

    private static final long serialVersionUID = -7192248251486130798L;

    /* Properties */

    ReminderMailSender reminderSender;

    /* Form fields */

    private String[] selectedRoles;

    /* Action Methods */

    @Override
    public String execute() throws Exception {

        return SUCCESS;
    }

    public String send() throws Exception {

        reminderSender.setRoles(selectedRoles);

        reminderSender.sendReminders();

        return execute();
    }

    /* Getters and Setters */

    /**
     * @return the reminderSender
     */
    public ReminderMailSender getReminderSender() {
        return reminderSender;
    }

    /**
     * @param reminderSender
     *            the reminderSender to set
     */
    public void setReminderSender(final ReminderMailSender reminderSender) {
        this.reminderSender = reminderSender;
    }

    public List<JobFunction> getRoles() {
        return RecruitServiceLocator.getJobProvider().findAllJobFunctions();
    }

    /**
     * @return the selectedRoles
     */
    public String[] getSelectedRoles() {
        return selectedRoles;
    }

    /**
     * @param selectedRoles
     *            the selectedRoles to set
     */
    public void setSelectedRoles(final String[] selectedRoles) {
        this.selectedRoles = selectedRoles;
    }
}